package com.WJY.dao;

import com.WJY.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentDao {
    //查询所有
    @Select("select * from demo.student")
    List<Student> queryStudentList();

    //id查询
    @Select("select * from demo.student where studentId = #{id}")
    Student queryStudentById(@Param("id") int id);

    //姓名查询
    @Select("select * from demo.student where studentName like '%${name}%'")
    List<Student> queryStudentByName(@Param("name") String name);

    //id删除
    @Delete("delete from demo.student where studentId = #{id}")
    int delStudent(@Param("id") int id);

    //新增
    @Insert("insert into demo.student (studentId, studentName, className, classTeacher) values (#{studentId},#{studentName},#{className},#{classTeacher})")
    int addStudent(Student student);

    //更新
    @Update("update demo.student set studentName = #{studentName},className = #{className},classTeacher = #{classTeacher} where studentId = #{studentId} ")
    int updateStudent(Student student);

}
